from Page.Page import Page
from Page.Page1 import Page1
from Page.Page2 import Page2
import time, unittest
from selenium import webdriver
from selenium.webdriver.common.by import By


class TestCase(unittest.TestCase):

    def setUp(self):
        self.driver = webdriver.Chrome()
        self.driver.maximize_window()


    def tearDown(self):
        time.sleep(5)
        self.driver.quit()

    def test_activity_01(self):
        po = Page(self.driver)
        po.activity_luoji_01()
        time.sleep(2)
        # 断言：
        alert = self.driver.switch_to.alert
        dy1 = alert.text
        self.assertIn('登录成功', dy1)
        alert.accept()

    def test_activity_02(self):
        po = Page1(self.driver)
        po.activity_luoji_02()
        time.sleep(2)
        # 断言：
        alert = self.driver.switch_to.alert
        dy1 = alert.text
        self.assertIn('报名成功', dy1)
        alert.accept()

    def test_activity_03(self):
        po = Page1(self.driver)
        po.activity_luoji_03()
        time.sleep(2)
        # 断言：
        alert = self.driver.switch_to.alert
        dy1 = alert.text
        self.assertIn('报名取消', dy1)
        alert.accept()

    def test_activity_04(self):
        po = Page2(self.driver)
        po.activity_luoji_04()
        time.sleep(2)
        # 断言：
        dy1 = self.driver.find_element(By.XPATH, '/html/body/div[1]/div/section/section/main/h2').text
        self.assertIn('后台', dy1)




if __name__ == '__main__':
    unittest.main()



